package com.crt.uav.exception;


import org.apache.hc.core5.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.crt.uav.domain.Result;

import jakarta.servlet.http.HttpServletResponse;

@RestControllerAdvice
public class CustomGlobalExceptionHandler {

    private static Logger LOOGER = LoggerFactory.getLogger(CustomGlobalExceptionHandler.class);

    @ExceptionHandler(Exception.class)
    public Result handleException(HttpServletResponse httpServletResponse ,Exception e) {
        // 处理异常
        httpServletResponse.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        LOOGER.error("系统异常--", e);
        return Result.error(500, "系统异常，请稍后再试");
    }
}
